<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>

		<link type="text/css" rel="stylesheet" href="../resources/css/bootstrap.min.css" />
	<link type="text/css" rel="stylesheet" href="../resources/css/style.css" />
	<script type="text/javascript" src="../resources/js/jquery.js"></script>
	<script type="text/javascript" src="../resources/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="../resources/js/jquery-ui.js"></script>
	<link type="text/css" rel="stylesheet" href="../resources/css/jquery-ui.css" />
	
	<link type="text/css" rel="stylesheet" href="../resources/css/jquery.ui.timepicker.css" />
	<script type="text/javascript" src="../resources/js/jquery.ui.core.min.js"></script>
	<script type="text/javascript" src="../resources/js/jquery.ui.widget.min.js"></script>
	<script type="text/javascript" src="../resources/js/jquery.ui.tabs.min.js"></script>
	<script type="text/javascript" src="../resources/js/jquery.ui.position.min.js"></script>
	<script type="text/javascript" src="../resources/js/jquery.ui.timepicker.js"></script>
	
	<script>
		$(function() {
			$("#datepicker_hanchot").datepicker({ dateFormat: 'dd-mm-yy' });
		});

		
		$(document).ready(function(){
			$("#table #rows").click(function(){
				   $(this).addClass('selected').siblings().removeClass('selected');   
				   var idphancong = $(this).find('td:eq(0)').html();
				   var idcongvan = $(this).find('td:eq(1)').html();
				   var duocphancong = $(this).find('td:eq(2)').html();
				   var nguoiphancong = $(this).find('td:eq(3)').html();
				   var ngayphancong = $(this).find('td:eq(4)').html();
				   var hanchot = $(this).find('td:eq(5)').html();
				   	$('#idphancong').val(idphancong);
				  	$('#idcongvan').val(idcongvan);
				  	$('#duocphancong').val(duocphancong);
				  	$('#nguoiphancong').val(nguoiphancong);
				  	$('#duocphancong').val(duocphancong);
				  	$('#ngayphancong').val(ngayphancong);
				  	$('#datepicker_hanchot').val(hanchot);
				  	$('#xacnhanhoantat').prop('disabled', true);
				  	
				  	if ($('#xacnhanhoantat_tb').is(":checked"))
				  	{
				  		$('#xacnhanhoantat').prop('checked', true);
				  	}
				  	if ($('#xacnhanbcn_tb').is(":checked"))
				  	{
				  		$('#xacnhanbcn').prop('checked', true);
				  	}
				  })
				  
		});	
	</script>

<!-- MODAL SUA CONG VAN DEN -->
<div class="modal fade s" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Sửa chi tiết phân công</h4>
</div>
<div class="modal-body">
	<form action="/QLKhoaCNTT/capnhatphancong"  method="post" class="form-horizontal" accept-charset="UTF-8">
		<div class="form-group">
				<label for="idphancong" class="col-lg-3 control-label">ID Phân công</label>
				<div class="col-lg-9">
				<input class="form-control" id="idphancong" name="idphancong" readonly type="text">
				</div>
			</div><!-- end form-group-->
		<div class="form-group">
			<label for="idcongvan" class="col-lg-3 control-label">Ký hiệu công văn</label>
			<div class="col-lg-9">
			<input class="form-control" id="idcongvan" name="idcongvan" readonly type="text">
			</div>
		</div><!-- end form-group-->

		<div class="form-group">
			<label for="trichYeu" class="col-lg-3 control-label">GV/BM được phân công</label>
			<div class="col-lg-9">
			<input class="form-control" id="duocphancong" name="idcongvan" readonly type="text">
			</div>
		</div>
		
		<div class="form-group">
			<label for="ngayNhan" class="col-lg-3 control-label">Người phân công</label>
			<div class="col-lg-9">
			 <input class="form-control" type="text" id="nguoiphancong" readonly>
			</div>
		</div><!-- end form-group-->
		
		<div class="form-group">
			<label for="ngayNhan" class="col-lg-3 control-label">Ngày phân công</label>
			<div class="col-lg-9">
			 <input class="form-control" type="text" id="ngayphancong" readonly>
			</div>
		</div><!-- end form-group-->
		
		<div class="form-group">
			<label for="ngayNhan" class="col-lg-3 control-label">Hạn chót</label>
			<div class="col-lg-9">
			 <input class="form-control" type="text" name="hancuoi" id="datepicker_hanchot">
			 <div class="checkbox">
          <label>
            <input type="checkbox" id="xacnhanhoantat" name="xacnhanhoantat" readonly> Xác nhận hoàn tất
          </label>
        </div>
        <div class="checkbox">
          <label>
            <input type="checkbox" id="xacnhanbcn" name="xacnhanbcn"> Xác nhận BCN
          </label>
        </div>
			</div>
		</div><!-- end form-group-->

		<button type="button" class="btn btn-default" data-dismiss="modal">Đóng</button>
		<button type="submit" class="btn btn-primary">Lưu</button>

	</form>
</div><!-- END modal-body -->
</div><!-- END modal-content -->
</div><!-- END modal-dialog modal-lg -->
</div><!-- END modal fade bs-example-modal-lg -->
<!-- END MODAL SUA CONG VAN DEN -->

	<script type="text/javascript">
	function trovetrangtruoc(){
		window.history.back();
	}
	
	</script>

<a class="btn btn-primary" onclick="trovetrangtruoc()">Trở về</a>

<c:choose>
	<c:when test="${!empty listPhanCong}">
		<table class="table table-hover" id="table">
		<tr>
			<th width="80">ID Phân công</th>
			<th width="80">Mã Công Văn</th>
			<th width="80">GV/BM được phận công</th>
			<th width="120">Người phân công</th>
			<th width="120">Ngày phân công</th>
			<th width="120">Hạn cuối</th>
			<th width="120">Xác nhận hoàn tất</th>
			<th width="120">Xác nhận BCN</th>
			<th width="80">Sửa</th>
			<th width="80">Xóa</th>			
		</tr>
		<c:forEach items="${listPhanCong}" var="phancong">
		<c:if test="${!empty phancong.phancongcongvandenGiangvien.giangvien.canbo.tenCanBo}">
			<tr id="rows">
				<td>${phancong.idPhanCong}</td>
				<td>${phancong.congvanden.idCongVanDen}</td>
				<td>${phancong.phancongcongvandenGiangvien.giangvien.canbo.tenCanBo}</td>
				<td>${phancong.nguoiPhanCong}</td>
				<td><fmt:formatDate value="${phancong.ngayPhanCong}" pattern="dd-MM-yyyy" /></td>
				<td><fmt:formatDate value="${phancong.hanCuoi}" pattern="dd-MM-yyyy" /></td>
				<c:choose>
					<c:when test="${phancong.xacNhanHoanTat == 1}">
						<td><input type="checkbox" id="xacnhanhoantat_tb" checked/></td>
					</c:when>
					<c:otherwise>
						<td><input type="checkbox" id="xacnhanhoantat_tb" /></td>
					</c:otherwise>
				</c:choose>
				<c:choose>
					<c:when test="${phancong.xacNhanBcn == 1}">
						<td><input type="checkbox" id="xacnhanbcn_tb" checked/></td>
					</c:when>
					<c:otherwise>
						<td><input type="checkbox" id="xacnhanbcn_tb"/></td>
					</c:otherwise>
				</c:choose>
				<td><button type="button" class="btn btn-primary" data-toggle="modal" data-target=".s">Sửa</button></td>
				<td><a class="btn btn-primary" href="#">Xóa</a></td>
			 </tr>
		</c:if>
			</c:forEach>
		<c:forEach items="${listPhanCong}" var="phancong">
			<c:if test="${!empty phancong.phancongcongvandenBomon.bomon.tenBoMon}">
			<tr id="rows">
				<td>${phancong.idPhanCong}</td>
				<td>${phancong.congvanden.idCongVanDen}</td>
				<td>${phancong.phancongcongvandenBomon.bomon.tenBoMon}</td>
				<td>${phancong.nguoiPhanCong}</td>
				<td><fmt:formatDate value="${phancong.ngayPhanCong}" pattern="dd-MM-yyyy" /></td>
				<td><fmt:formatDate value="${phancong.hanCuoi}" pattern="dd-MM-yyyy" /></td>
				<c:choose>
					<c:when test="${phancong.xacNhanHoanTat == 1}">
						<td><input type="checkbox" id="xacnhanhoantat_tb" checked/></td>
					</c:when>
					<c:otherwise>
						<td><input type="checkbox" id="xacnhanhoantat_tb"/></td>
					</c:otherwise>
				</c:choose>
			<c:choose>
					<c:when test="${phancong.xacNhanBcn == 1}">
						<td><input type="checkbox" id="xacnhanbcn_tb" checked/></td>
					</c:when>
					<c:otherwise>
						<td><input type="checkbox" id="xacnhanbcn_tb"/></td>
					</c:otherwise>
				</c:choose>
				<td><button type="button" class="btn btn-primary" data-toggle="modal" data-target=".s" id="sua">Sửa</button></td>
				<td><a class="btn btn-primary" href="#">Xóa</a></td>
			 </tr>
			 </c:if>
			</c:forEach>
		
	</table>				
	</c:when>
	<c:otherwise>
		<div class="alert alert-dismissable alert-warning">
  <button type="button" class="close" data-dismiss="alert">×</button>
  <p>Không có phân công công văn đến nào để hiển thị !!!</p>
</div>								
	</c:otherwise>
</c:choose>

	
